#ifndef _MAP_H_
#define _MAP_H_

class CMap;

#include "Path.h"

#define SEARCH_QUEUE_SIZE	1024
#define MAX_MAP_SIZE		256

class CMap
{
private:
	unsigned short m_mapWidth;
	unsigned short m_mapHeight;

	unsigned char m_obstacleMap[MAX_MAP_SIZE][MAX_MAP_SIZE];

//for search
	unsigned short m_searchData[MAX_MAP_SIZE][MAX_MAP_SIZE];

	short m_sQueueX[SEARCH_QUEUE_SIZE];
	short m_sQueueY[SEARCH_QUEUE_SIZE];

	short m_sQueuePos;
	short m_sQueueLen;
	bool m_sAbortSearch;

	int m_sLastX;
	int m_sLastY;
	bool m_sResetSearch;

	void s_SetValue(int x, int y, unsigned short v);

public:
	CMap(char *fname);
	bool searchPath(int xDest, int yDest, int xSrc, int ySrc, CPath *path);
	bool isObstacleAt(int x, int y);
	bool canDrawLine(int x1, int y1, int x2, int y2);
	void save(char *fname, CPath *path);
};

#endif //_MAP_H_